<!DOCTYPE HTML>
<html>
<head>
    <title>登录</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="/js/jquery.min.js"></script>
    <script src="/js/jQuery.md5.js"></script>
    <script src="/js/common.js"></script>

</head>
<script>

    function login() {
        var username = $("#username").val();
        var password = $("#password").val();
        if (username.length == 0) {
            //  alert('请输入用户名');
            $("#alert1").show() ;
            $("#alert").html('请输入用户名') ;
            return false;
        }
        if (password.length == 0) {
            $('#alert1').show() ;
            $('#alert').html('请输入密码') ;
            return false;
        }

        $.ajax({
            type: "GET",
            url: "/login/",
            data: "p=" +password + "&u=" + username + "&time=" + new Date(),
            success: function (result) {
                if (result == "1") {

                    window.location.href = "/index/"
                    return false;
                }
                else {
                    $("#alert1").show() ;
                    $("#alert").html('登录失败 用户名或者密码错误') ;
                    return false;

                }
            }
        });

    }
    document.onkeydown = function (e) {
        if (!e) e = window.event;
        if ((e.keyCode || e.which) == 13) {
            $(".btn").click();
        }
    }

</script>
<body>

    <div class="container-fluid">
       <div class="container-fluid" style="display:none" id="alert1">

            <div class="row-fluid">
                <div class="span12">
                    <div class="alert alert-error">

                        <h4>
                            提示!
                        </h4> <strong>警告!</strong><div id="alert" ></div>
                    </div>
                </div>
            </div>
        </div>
        <!--中部-->
        <div class="container-fluid" role="navigation">
            <div class="row-fluid">

                <div class="span12">


                    <div class="row-fluid">
                        <div class="span12">
                            <div class="span2"><p class="text-left">用户名: </p></div>
                            <div class="span10"><input type="text" class="search-query" placeholder="请输入登录名" id="username"/>
                            </div>
                        </div>
                    </div>
                    <div class="row-fluid">
                        <div class="span12">
                            <div class="span2"><p class="text-left">密码: </p></div>
                            <div class="span10"><input type="password" class="search-query" placeholder="请输入密码"
                                                       id="password"/></div>
                        </div>
                    </div>
                    <div class="row-fluid">
                        <div class="span12">
                            <a class="btn" onclick="login()" href="#">登 录</a>
                        </div>
                    </div>


                </div>
            </div>
        </div>

        <!--中部-->
    </div>
</body>
</html>